<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../common/jspcommon.jsp"%>
<%@include file="../common/jscss.jsp"%>
<script type="text/javascript">
	var grid_ae = null;
	var dialog_ae = null;
	$(function(){
		grid_ae = $("#ticket_grid").ligerGrid({
				checkbox: true,
				title : '${scenic.name}  门票列表',
                columns: [
                { display: '门票id', name: 'id', isSort : false, width: 120 },
                { display: '名称', name: 'name',isSort : false, width: 230 },
                { display: '类型', name: 'type',isSort : false, width: 60,
                	render:function(record, rowindex, value, column){
                		if(value=='01'){
                			return "电子票";
                		}else if(value=='02'){
                			return "实体票";
                		}else if(value=='03'){
                			return "电子票到付";
                		}
                	}	
                }, 
                { display: '创建时间', name: 'gmtCreated',isSort : false,
                  render: function(record, rowindex, value, column){
                	 return (new Date(value.time)).format("yyyy年MM月dd日 hh:mm:ss");
                  }}, 
                { display: '最后修改时间', name: 'gmtModified',isSort : false,
                  render: function(record, rowindex, value, column){
                	 return (new Date(value.time)).format("yyyy年MM月dd日 hh:mm:ss");
                  }
                },
                {
                	display: '<a href="javascript:;" onclick="addTicket()">新增门票</a>', 
                	name: 'id',
                	isAllowHide: false, 
                	isSort : false,
                	width: 200,
					render: function (record, rowindex, value, column){
					//this     这里指向grid
					//record   行数据
					//rowindex 行索引
					//value    当前的值，对应record[column.name]
					//column   列信息
						var html = '<a onclick="priceDetail(\''+ value + '\')" href="javascript:;">详细日期价格</a>&nbsp;<a onclick="editTicket(\''+ value + '\')" href="javascript:;">编辑</a>&nbsp;<a onclick="deleteTicket(\''+ value + '\')" href="javascript:;">删除</a>'; 
						return html; 
					}
                }
                ], 
                pageSize:10,
                root :'list',
                record:'totalRecord',
                url: "/misc/ticket/ticketGrid.htm?scId=${scenic.id}", 
                width: '99%',height:'99%',
                isChecked: f_isChecked, onCheckRow: f_onCheckRow, onCheckAllRow: f_onCheckAllRow
            });

		$("#parent").ligerComboBox({
			width : 215,
			selectBoxWidth : 215,
			selectBoxHeight : 180,
			valueField : 'mark',
			textField : 'text',
			treeLeafOnly : false,
			tree : {
				checkbox : false,
				btnClickToToggleOnly : false,
				url : '/misc/cms/channelTree.htm'
			}
		});

	});
	
	function deleteTicket(ticketId){
		$.ligerDialog.confirm('你真的要删除吗？', 
			function (yes){
				if(yes){
					$.post("/misc/ticket/deleteTicket.htm",{ticketId:ticketId}); 
					grid_ae.loadData();
				}
			});
	}
	
	function editTicket(id){
		dialog_ae = $.ligerDialog.open({ height: 400,width:900, url: "/misc/ticket/editTicket.htm?id="+id, showMax:true,showMin:true,isResize:true,isDrag:false,title:'编辑门票'});
	}
	
	function addTicket(){
		dialog_ae = $.ligerDialog.open({ height: 400,width:900, url: "/misc/ticket/addTicket.htm?scId=${scenic.id}", showMax:true,showMin:true,isResize:true,isDrag:false,title:'新增门票'});
	
	}
	
	function priceDetail(id){
		dialog_ae = $.ligerDialog.open({ height: 500,width:700, url: "/misc/ticket/priceDetail.htm?ticketId="+id, showMax:true,showMin:true,isResize:true,isDrag:false,title:'详细日期价格	'});
	}
		
	function search(){
		grid_ae.options.parms = [{name:'name',value:$("#search_name").val()}];
		grid_ae.loadData();
	}
	
</script>
<table>
	<tr>
		<td>
			<div id="searchbar" >
				票名：<input id="search_name" type="text" value="${name}"/>
			    <button id="btnOK" type="button" onclick="search()" >查询</button>
			</div>
		</td>
		<td><input type="text" id="parent"/><button onclick="pushTicket()" id="tui_song" style="position:relative;left:220px;top:-22px; margin:0 0 -20px 0;">推送</button></td>
	</tr>
</table>

<div id="ticket_grid" style="margin:0; padding:0"></div>
